package com.sneaker.shower.config.socket;


import com.sneaker.shower.socket.Channel;
import com.sneaker.shower.socket.ChannelSign;
import com.sneaker.shower.socket.StandarChannel;
import com.sneaker.shower.socket.common.PSWsRequest;
import org.springframework.web.socket.WebSocketSession;

/**
 * <h1>DefaultChannelBuilder</h1>
 * <pre>
 * @Description
 * </pre>
 *
 * @Author lopo
 * @Date 2018/10/22
 */
public class DefaultChannelBuilder implements ChannelBuilder {
    public Channel buildChannel(PSWsRequest request, WebSocketSession session){
        String orgId = (String) request.getHeader().get(PSWsRequest.HEADER_ORG_ID);
        String accountId = (String) request.getHeader().get(PSWsRequest.HEADER_ACCOUNT_ID);
        ChannelSign channelSign = new ChannelSign(orgId,accountId, session.getId());
        StandarChannel standarChannel = new RegisteredChannel(channelSign,session);
        standarChannel.start();
        return standarChannel;
    }
}
